class FollowUpWorker < BackgrounDRb::MetaWorker
  set_worker_name :follow_up_worker
  
  def do_work()
    logger.info 'Fetching notifications'
    conversations = Conversation.find(:all, :conditions => ["follow_up = true and follow_up_date < :now and notification_sent is null", {:now => Time.now}])
    conversations.each do |conversation|
      logger.info 'Sending notification to ' + conversation.user.email
      Notifier.deliver_follow_up(conversation)
      conversation.notification_sent = Time.now
      conversation.save
    end
  end
end
